n00b needs some PHP syntax guidance [closed]
Posted
by
Michael
on Pro Webmasters
See other posts from Pro Webmasters
or by Michael
Published on 2011-02-20T02:16:52Z
Indexed on
2011/02/20
7:33 UTC
Read the original article
Hit count: 336
php
If you look at http://www.cruc.es/?paged=12/ and go to the bottom of the page you'll see the bottom navigation with the next and previous options. I've been able to make the page numbers work by changing page to paged= in the code. I don't know enough about PHP to get the previous/next options to work. Any advice would be appreciated and I've pasted the code below.
Thank you: n00b
if ( $query->found_posts > $query->query_vars["posts_per_page"] ) {
echo '<ul class="paging">';
// Previous link?
if ( $page > 1 ) {
echo '<li class="previous"><a href="'.$baseURL.'/page/'.($page-1).'/'.$qs.'">previous</a></li>';
}
// Loop through pages
for ( $i=1; $i <= $query->max_num_pages; $i++ ) {
// Current page or linked page?
if ( $i == $page ) {
echo '<li class="active">'.$i.'</li>';
} else {
echo '<li><a href="'.$baseURL.'/?paged='.$i.'/'.$qs.'">'.$i.'</a></li>';
}
}
// Next link?
if ( $page < $query->max_num_pages ) {
echo '<li><a href="'.$baseURL.'/page/'.($page+1).'/'.$qs.'">next</a></li>';
}
echo '</ul>';
}
© Pro Webmasters or respective owner